<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $bugs = new Application_Model_DbTable_Bugs();
        $pais = new Application_Model_DbTable_Pais();
        
        //**********************************************************
        // Devuelve el cursor de la tabla Bugs sin filtros
        //$this->view->bugs = $bugs->fetchAll();
        //$this->view->rowCount = count($bugs->fetchAll());
        
        //**********************************************************
        // Devuelve el cursor de la tabla Bugs aplicando filtros
        //$filtro_01 = "Resolved";
        //$this->view->bugs = $bugs->fetchAll("bug_status = 'Resolved'");
        //$this->view->bugs = $bugs->fetchAll("bug_status = .$filtro_01");
        
        
        
        //**********************************************************
        // Devuelve el una fila en el formato de array variable => valor
        //$row = $bugs->fetchRow($bugs->select()->where('bug_id = ?', 1));
        //$rowArray = $row->toArray();
        //$this->view->rowArray = $rowArray;
        

        // Devolver la estructura del flexigrid con la tabla de paises
        
        $cursorPais = $pais->fetchAll();
        $rowCount = count($pais->fetchAll());
        
        $data = array('page'=>"'1'");
        // se inserta el elemento total
        $data['total']="'$rowCount'";
		
        $cell = array();
        $rows = array();
        
        foreach ($cursorPais as $pais) 
        {
         // Se convierte la fila en un array(respeta clave=>valor)
         $rowPais = $pais->toArray();
         $dataRow = array();
         $dataRow['id'] = $pais->id;
         $dataRow['cell'] = $rowPais;
         array_push($rows,$dataRow);
        }
        $data['rows'] = $rows;

        $this->view->data = $data;
        $this->view->cursorPais = $cursorPais;

        
        
        
    }


}

